import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TIntegralShop } from "../../../Message/Db/Tables/TIntegralShop";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class IntegralShopConfig
    
    export  class IntegralShopConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._infoArr = new Array<any>();
            if (IntegralShopConfig._instance != null) 
            {
                throw new Error("IntegralShopConfig 单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_integral_shop.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TIntegralShop();
                loc1.id = loc2.id;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.type = loc2.type;
                loc1.priceUnit = loc2.priceUnit;
                loc1.level = loc2.level;
                loc1.minPlayerLevel = loc2.minPlayerLevel;
                loc1.itemKindNums = loc2.itemKindNums;
                loc1.info = loc2.info;
                this._map[loc1.id] = loc1;
                this._infoArr.push(loc1);
            }
            return;
        }

        public getIntegralShopArray(arg1: int, arg2: int, arg3: int): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            while (loc3 < this._infoArr.length) 
            {
                if ((loc2 = this._infoArr[loc3]).priceUnit == arg1 || loc2.priceUnit == arg2 || loc2.priceUnit == arg3) 
                {
                    loc1.push(loc2);
                }
                ++loc3;
            }
            return loc1;
        }

        public getShopInfoById(arg1: int): TIntegralShop
        {
            return this._map[arg1] as TIntegralShop;
        }

        public getUnitByShopId(arg1: int): int
        {
            var loc1=0;
            var loc2=this.getShopInfoById(arg1);
            if (loc2) 
            {
                loc1 = loc2.priceUnit;
            }
            return loc1;
        }

        public static get instance(): IntegralShopConfig
        {
            if (IntegralShopConfig._instance == null) 
            {
                IntegralShopConfig._instance = new IntegralShopConfig();
            }
            return IntegralShopConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_infoArr: Array<any>;

        /* internal */ static /* var */_instance: IntegralShopConfig;
    }
